<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Welcome to Car Rent Inc</title>
</h:head>
<ui:composition template="/templates/frame.xhtml">
	<ui:param name="activeIndex" value="2" />
	<ui:define name="page">
		<h:form id="closedRequestsForm">
			<rich:dataTable value="#{closedRequestBean.requests}" var="item"
				iterationStatusVar="it" id="requestTable" border="1"
				styleClass="center">
				<f:facet name="header">
					<h:outputText value="Closed requests" />
				</f:facet>
				<rich:column>
					<f:facet name="header">#</f:facet>
                #{it.index}
            	</rich:column>
				<rich:column>
					<f:facet name="header">Car</f:facet>
					<h:outputText value="#{item.car.manufacturer}" />
					<h:outputText value="#{item.car.model}" />
				</rich:column>
				<rich:column>
					<f:facet name="header">Car Number</f:facet>
					<h:outputText value="#{item.car.number}" />
				</rich:column>
				<rich:column>
					<f:facet name="header">beginDate</f:facet>
					<h:outputText value="#{item.beginDate}">
						<f:convertDateTime pattern="dd.MM.yyyy" />
					</h:outputText>
				</rich:column>
				<rich:column>
					<f:facet name="header">endDate</f:facet>
					<h:outputText value="#{item.endDate}">
						<f:convertDateTime pattern="dd.MM.yyyy" />
					</h:outputText>
				</rich:column>
				<rich:column>
					<f:facet name="header">Request status</f:facet>
					<h:outputText value="#{item.status}" />
				</rich:column>
			</rich:dataTable>
			<div style="text-align: center;">
				<a4j:commandButton value="first"
					action="#{closedRequestBean.pageFirst}"
					disabled="#{closedRequestBean.firstRow == 0}"
					render="closedRequestsForm" execute="@this" />
				<a4j:commandButton value="prev"
					action="#{closedRequestBean.pagePrevious}"
					disabled="#{closedRequestBean.firstRow == 0}"
					render="closedRequestsForm" execute="@this" />
				<a4j:commandButton value="next"
					action="#{closedRequestBean.pageNext}"
					disabled="#{closedRequestBean.firstRow + closedRequestBean.rowsPerPage >= closedRequestBean.totalRows}"
					render="closedRequestsForm" execute="@this" />
				<a4j:commandButton value="last"
					action="#{closedRequestBean.pageLast}"
					disabled="#{closedRequestBean.firstRow + closedRequestBean.rowsPerPage >= closedRequestBean.totalRows}"
					render="closedRequestsForm" execute="@this" />
				<h:outputText
					value="Page #{closedRequestBean.currentPage} / #{closedRequestBean.totalPages}" />
			</div>
		</h:form>
	</ui:define>
</ui:composition>

</html>